class Solution {
    public ListNode swapPairs(ListNode head) {
        if (head != null && head.next != null) {
            ListNode node = head.next;
            head.next = swapPairs(head.next.next);
            node.next = head;
            return node;
        }
        return head;
    }
}